<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

  <img src="https://hrsass-1312861783.cos.ap-chongqing.myqcloud.com/485-f778.gif" alt="">
  
  <script>

    const img = document.querySelector('img')

    img.addEventListener('error', function() {
      console.log('图片加载失败的时候, 触发事件')
    })

  </script>
</body>
</html>